import 'dart:convert';

T? asT<T>(dynamic value) {
  if (value is T) {
    return value;
  }
  return null;
}

class Area {
  Area({
    this.Code,
    this.ListArea,
  });

  factory Area.fromJson(Map<String, dynamic> jsonRes) {
    final List<List_area>? listArea =
        jsonRes['list_area'] is List ? <List_area>[] : null;
    if (listArea != null) {
      for (final dynamic item in jsonRes['list_area']!) {
        if (item != null) {
          listArea.add(List_area.fromJson(asT<Map<String, dynamic>>(item)!));
        }
      }
    }
    return Area(
      Code: asT<int?>(jsonRes['code']),
      ListArea: listArea,
    );
  }

  int? Code;
  List<List_area>? ListArea;

  @override
  String toString() {
    return jsonEncode(this);
  }

  Map<String, dynamic> toJson() => <String, dynamic>{
        'code': Code,
        'list_area': ListArea,
      };
}

class List_area {
  List_area({
    this.Id,
    this.Name,
    this.Pid,
    this.ChildrenArea,
  });

  factory List_area.fromJson(Map<String, dynamic> jsonRes) {
    final List<Children_area>? childrenArea =
        jsonRes['children_area'] is List ? <Children_area>[] : null;
    if (childrenArea != null) {
      for (final dynamic item in jsonRes['children_area']!) {
        if (item != null) {
          childrenArea
              .add(Children_area.fromJson(asT<Map<String, dynamic>>(item)!));
        }
      }
    }
    return List_area(
      Id: asT<String?>(jsonRes['id']),
      Name: asT<String?>(jsonRes['name']),
      Pid: asT<String?>(jsonRes['pid']),
      ChildrenArea: childrenArea,
    );
  }

  String? Id;
  String? Name;
  String? Pid;
  List<Children_area>? ChildrenArea;

  @override
  String toString() {
    return jsonEncode(this);
  }

  Map<String, dynamic> toJson() => <String, dynamic>{
        'id': Id,
        'name': Name,
        'pid': Pid,
        'children_area': ChildrenArea,
      };
}

class Children_area {
  Children_area({
    this.Id,
    this.Name,
    this.Pid,
  });

  factory Children_area.fromJson(Map<String, dynamic> jsonRes) => Children_area(
        Id: asT<String?>(jsonRes['id']),
        Name: asT<String?>(jsonRes['name']),
        Pid: asT<String?>(jsonRes['pid']),
      );

  String? Id;
  String? Name;
  String? Pid;

  @override
  String toString() {
    return jsonEncode(this);
  }

  Map<String, dynamic> toJson() => <String, dynamic>{
        'id': Id,
        'name': Name,
        'pid': Pid,
      };
}
